import { Navigate } from "react-router-dom";
import { lazy } from "react";
import AuthComponent from "../utils/Authcomponent";
// import AuthComponent from "../utils/AuthComponent";
var Index = lazy(() => import('../views/Index'));
var Login = lazy(() => import('../views/Login'));
var Register = lazy(() => import('../views/Register'));
var NotFound = lazy(() => import('../views/NotFound'));

// 二级路由
var Home = lazy(() => import('../views/Index/Home'));
var Authoritymanage = lazy(() => import('../views/Index/Authoritymanage'));
var Studentmange = lazy(() => import('../views/Index/Studentmange'));
var Areaofrisk = lazy(() => import('../views/Index/Areaofrisk'));
var Tripmanage = lazy(() => import('../views/Index/Tripmanage'));
var Healthymange = lazy(() => import('../views/Index/Healthymange'));
var Leavemanage = lazy(() => import('../views/Index/Leavemanage'));
var Outbreak = lazy(() => import('../views/Index/Outbreak'));
// 三极路由
var StudentsInfo = lazy(() => import('../views/Index/students/StudentsInfo'));
var StudentEcharts = lazy(() => import('../views/Index/students/StudentEcharts'));


var AddTrip = lazy(() => import('../views/Index/TripAdd'))
var AddHealth = lazy(() => import('../views/Index/HealthAdd'))
var School = lazy(() => import('../views/Index/SchoolNumber'))
var Personcenter = lazy(() => import('../views/Index/Personcenter'));
var Stu = lazy(() => import('../views/Index/students/Stu'))
// 三级路由
var Listofroles = lazy(() => import('../views/Index/Authoritymange/Listofroles'));
var Permissionlist = lazy(() => import('../views/Index/Authoritymange/Permissionlist'));

var Annun = lazy(() => import('../views/Index/AddAnnun'))
var Detail = lazy(() => import('../views/Index/Details'))

const routes = [
    {
        path: '/index',
        element: <Index />,
        children: [
            {
                path: '/index/home',
                element: <AuthComponent permission={1}><Home /></AuthComponent>,
            },
            // 个人中心页
            {
                path: "/index/personcenter",
                element: <Personcenter />
            },
            {
                path: '/index/authoritymanage',
                element: <AuthComponent permission={2}><Authoritymanage /></AuthComponent>,
                children: [
                    {
                        path: '/index/authoritymanage/listofroles',
                        element: <AuthComponent permission={21}><Listofroles /></AuthComponent>,
                    },
                    {
                        path: '/index/authoritymanage/permissionlist',
                        element: <AuthComponent permission={22}><Permissionlist /></AuthComponent>,
                    },
                    // 三级404路由和重定向路由
                    // 三级路由重定向
                    {
                        path: '/index/authoritymanage',
                        element: <Navigate to='/index/authoritymanage/listofroles' />
                    },
                    // 一级404路由
                    {
                        path: '*',
                        element: <NotFound />
                    }
                ]
            },
            {
                path: '/index/studentmange',
                element: <AuthComponent permission={3}><Studentmange /></AuthComponent>,
                children: [
                    {
                        path: '/index/studentmange/studentsinfo',
                        element: < StudentsInfo />,
                    },
                    {
                        path: '/index/studentmange/studentsecharts',
                        element: <StudentEcharts />,
                    },
                    {
                        path: '/index/studentmange/stu',
                        element: <Stu />
                    },
                    {
                        path: '/index/studentmange',
                        element: <Navigate to='/index/studentmange/studentsinfo' />
                    },

                    // 3级404路由
                    {
                        path: '*',
                        element: <NotFound />
                    }
                ]
            },
            {
                path: '/index/areaofrisk',
                element: <AuthComponent permission={4}><Areaofrisk /></AuthComponent>,
            },
            {
                path: '/index/tripmanage',
                element: <AuthComponent permission={5}><Tripmanage /></AuthComponent>,
            },

            //校园疫情Echarts图表
            {
                path: '/index/schoolnumber',
                element: <School />
            },
            //健康上报添加页面
            {
                path: '/index/healthymangeadd',
                element: <AuthComponent permission={161}><AddHealth /></AuthComponent>

            },
            //行程信息添加
            {
                path: '/index/tripadd',
                element: <AuthComponent permission={151}><AddTrip /></AuthComponent>
            },
            {
                path: '/index/healthymange',
                element: <AuthComponent permission={6}><Healthymange /></AuthComponent>,
            },
            {
                path: '/index/leavemanage',
                element: <AuthComponent permission={7}><Leavemanage /></AuthComponent>,
            },
            {
                path: '/index/outbreak',
                element: <AuthComponent permission={8}><Outbreak /></AuthComponent>,
            },
            {
                path: '/index/addannun',
                element: <Annun />,
            },
            {
                path: '/index/detail/:id',
                element: <Detail />,
            },
            // 二级404路由和重定向路由
            // 二级路由重定向
            {
                path: '/index',
                element: <Navigate to='/index/home' />
            },
            // 一级404路由
            {
                path: '*',
                element: <NotFound />
            }

        ]
    },
    {
        path: '/login',
        element: <Login />
    },
    {
        path: '/register',
        element: <Register />
    },
    // 一级路由重定向
    {
        path: '/',
        element: <Navigate to='/index' />
    },
    // 一级404路由
    {
        path: '*',
        element: <NotFound />
    }
]
export default routes;